package com.kylin.common.core.entity;

import com.alibaba.fastjson2.annotation.JSONField;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.kylin.common.core.util.ServletUtils;

import java.util.List;

/**
 * 重写MyBatisPlus分页对象
 *
 * @author wuhao
 * @version 1.0 - 2019-02-19
 */
public class Page<T> extends com.baomidou.mybatisplus.extension.plugins.pagination.Page<T> {

    /**
     * 当前页码
     */
    public static final String CURRENT_PAGE = "pageNum";
    /**
     * 每页显示记录数
     */
    public static final String LIMIT = "pageSize";

    /**
     * 设置分页参数
     * @return
     * @version 1.0  by wuhao at 2019/7/5
     */
    public Page(){

        //当前页码
        Integer current = ServletUtils.getParameterToInt(CURRENT_PAGE, 1);
        //每页数据大小
        Integer size = ServletUtils.getParameterToInt(LIMIT, 10);

        setCurrent(current);
        setSize(size);
    }

    /***********************以下是为了解决序列化输出问题 ，并无实际作用 **************************/
    @Override
    @JSONField(serialize = false)
    public boolean isOptimizeCountSql() {
        return optimizeCountSql;
    }

    @Override
    @JSONField(serialize = false)
    public List<OrderItem> getOrders() {
        return this.orders;
    }

    @Override
    @JSONField(serialize =  false)
    public boolean isSearchCount() {
        return this.searchCount;
    }

    @Override
    @JSONField(serialize = false)
    public String getCountId() {
        return this.countId;
    }

    @Override
    @JSONField(serialize = false)
    public Long maxLimit() {
        return this.maxLimit;
    }

}
